package cn.sccdlg.ssm.service.impl;

import cn.sccdlg.ssm.dao.IProductDao;
import cn.sccdlg.ssm.domain.Product;
import cn.sccdlg.ssm.service.ProductService;
import cn.sccdlg.ssm.utils.UuidUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author RaoShuang
 * @emil 991207823@qq.com
 * @date 2020/10/27 23:09
 * 商品业务层实现类
 */
@Service("productService")
@Transactional(rollbackFor = {Exception.class, Error.class})
public class ProductServiceImpl implements ProductService {
    @Autowired
    private IProductDao productDao;

    @Override
    public Product findById(String id) throws Exception {
        return productDao.findById(id);
    }

    @Override
    public List<Product> findAll() throws Exception {
        return productDao.findAll();
    }

    @Override
    public void save(Product product) throws Exception {
        product.setId(UuidUtils.getUnid());
        productDao.save(product);
    }

    @Override
    public void update(Product product) throws Exception {
        productDao.update(product);
    }
}
